package src.queries;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;

import src.entities.RadRecord;

import  src.entities.User;
import  src.exceptions.InvalidLoginException;

public class Application {
	public static void main(String[] args){
		DBConnector dbConnect = new DBConnector();
		SecurityQueries security = null;
		UploadQueries upload = null;
		SearchQueries search = null;
		try {
			security = new SecurityQueries(dbConnect.getConnection());
			upload = new UploadQueries(dbConnect.getConnection(), security);
			search = new SearchQueries(dbConnect.getConnection(), security);
		} catch (ClassNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (InstantiationException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (IllegalAccessException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		Date fromDate = new Date(0);
		Date toDate = new Date();
		String searchwords = new String();
		ArrayList<RadRecord> results = new ArrayList<RadRecord>();
		searchwords= "cramps";
		
		String keywords = "user4";
		
		User user1 = new User(keywords, keywords, "d", new java.sql.Date(0), keywords, keywords,keywords, keywords, keywords);
		
		try{
		/*upload.createRadRecord("user1", "user2", "user3", "bone density", new Date(0), new Date(), "wonderful cramps", "checking for leg cramps");
		upload.createRadRecord("user1", "user4", "user3", "bone density", new Date(0), new Date(), "wonderful cramps", "checking for leg cramps");
		upload.createRadRecord("user3", "user2", "user5", "bone density", new Date(0), new Date(), "wonderful cramps", "checking for leg cramps");
		upload.createRadRecord("user1", "user2", "user3", "bone density", new Date(0), new Date(), "wonderful cramps", "checking for leg cramps");*/
		File image = new File("/home/dsk01/ugrad/jjlee2/workspace/291A3/c391_asn/src/queries/AssemblyKit1.jpg");
			
			
			
			results = search.search(searchwords, fromDate, toDate, user1);
			System.out.println(search.getFullSize(42));
			System.out.println(search.getRegularSize(42));
			System.out.println(search.getThumbNail(42));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		for(RadRecord result:results){
			System.out.println(result.getDescription()+"/"+result.getDiagnosis()+"/"+result.getDoctorName()+" patient:"+ result.getPatientName());
		}
		System.out.println("done");
		dbConnect.disconnect();


	}
}
